// 路由
// createRouter：用于创建vue-router示例对象
// RouteRecordRaw：用于规范路由规则，增加路由对象类型限制
// createWebHashHistory：用于指定路由工作模式（hash）
import {
  createRouter,
  type RouteRecordRaw,
  createWebHashHistory,
} from "vue-router";

// 引入store的userStore
// import { userStore } from "../store/user";

// 创建路由规则
const routes: RouteRecordRaw[] = [
  {
    path: "/",
    name: "Index",
    component: () => import("../views/Index.vue"),
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("../views/Login.vue"),
  },
  {
    path: "/vue3",
    children: [
      // {
      //   path: "/vue3",
      //   redirect: "/icon",
      // },
      {
        path: "reactive",
        name: "Reactive",
        component: () => import("../views/Vue3/Reactive.vue"),
      },
      {
        path: "watch",
        name: "Watch",
        component: () => import("../views/Vue3/Watch.vue"),
      },
      {
        path: "icon",
        name: "Icon",
        component: () => import("../views/Vue3/Icon.vue"),
      },
      // 可以继续添加更多子路由
    ],
  },
];
// 创建路由的示例对象
const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

// 路由导航守卫
// router.beforeEach((to, from, next) => {
//   const store = userStore();
//   if (store.token) {
//     next();
//   } else {
//     // 做导航守卫动作
//   }
// });
export default router;
